product_list=[('华为p30',3800),
              ('Mac Pro',16000),
              ('mike tea',15),
              ('crabs',88),
              ("Bike",800),
              ('watch',100050),
              ('head of python',128),
              ('book',100)]
shopping_car=[]
zhifubao=input('请输入支付宝余额')
print(type(zhifubao))
while True:
    zhifubao=int(zhifubao)
    for item in product_list:
        print(product_list.index(item),item)
    choice=input('请输入产品编号')
    if choice.isdigit():
        choice=int(choice)
        if choice >=0 and choice<8:
            if zhifubao>=product_list[choice][1]:
                zhifubao=zhifubao-product_list[choice][1]
                shopping_car.append(product_list[choice][0])
                print("你把商品%s添加到购物车支付宝余额是%s"%(product_list[choice]),(zhifubao))
                print(shopping_car)
            else:
                print('你的余额不足，请重新选择商品')
                print('请按Q退出')
        else:
            print('商品里没有这个列表，请重新选择一个商品')
    elif choice =='q':
        print('-----购物车清单----')
        for item in shopping_car:
            print(item)
        print('你的支付宝余额%s'%zhifubao)
        print(shopping_car)
        break
    else:
        print('请按Q退出程序')
else:
    print('请输入数字金额')
